<template>
	<view :style="'width:'+w+'%;height:'+h+'%;top:'+t+'rpx;right:'+r+'rpx'" class="gif">
		<image v-if="!show" class="img1" mode="widthFix" src="https://wechat-pictures-1301970825.file.myqcloud.com/jinbi.gif"></image>
		<image @click="lingqu"  mode="widthFix" class="show" v-if="show" src="https://wechat-pictures-1301970825.file.myqcloud.com/2c9506ab-c469-4cb4-897c-ce6e6aa216ae.png"></image>
		<view class="title" v-if="show">{{show_time}}S</view>
		<view class="title" v-if="show">自动关闭</view>
		<!-- <image class="img2" mode="heightFix" src="https://wechat-pictures-1301970825.file.myqcloud.com/gifjinbis.gif"></image> -->
		<video autoplay="true"  src="https://wechat-pictures-1301970825.file.myqcloud.com/jinbi.mp3"></video>
	</view>
</template>

<script>
	export default {
		name:"gifjinbi",
		props:['video_id','time_end'],
		data() {
			return {
				time:2,
				w:'100',
				h:'100',
				t:0,
				r:"0",
				m_t:350,
				show:false,
				show_time:0,
				aa:"",
				cc:""
			};
		},
		created() {
			var _this=this;
			_this.show_time=_this.time_end;
			 this.cc=setInterval(function(){
				_this.time=_this.time-1;
				if(_this.time==0){
					clearInterval(_this.cc)
					_this.donghua()
				}
				
			},1000)
			this.aa=setInterval(function(){
				if(_this.w<=20){
				_this.show_time=_this.show_time-1;
				if(_this.show_time<=0){
					clearInterval(_this.aa)
					_this.guanbi()
				}
				}
			},1000)
		},
		beforeDestroy(){
			clearInterval(this.aa)
			clearInterval(this.cc)
		        },
		methods:{
			donghua(){
				var _this=this;
				var i=1;
				var cc=setInterval(function(){
					i++
					if(_this.w<=20){
						_this.show=true;
						clearInterval(cc)
					}else{
						_this.w=_this.w-1;
						_this.h=_this.h-1;
						if(_this.t<=220){
							_this.t=_this.t+11;
						}
					
					}
				},10)
			},
			lingqu(){
				var _this=this;
				var data={
					video_id:this.video_id
				}
				_this.$api.doRequest("post","/api/scan_video_get_coin_fuli",data).then(res=>{
					if(res.data.code==200){
						uni.showToast({
							title:"领取成功"
						})
						setInterval(function(){
							_this.$emit("scan_video_get_coin_fuli",0);
						},3000)
						
					}
				})
			},
			guanbi()
			{
				
				var video_log_sum=uni.getStorageSync("video_log_sum");
				var num=parseInt(video_log_sum/3)
				this.$emit("scan_video_get_coin_fuli",num);
			}
		}
	}
</script>

<style>
   .gif{
/* 	   width: 100vw;
	   height: 100vh; */
	   position: fixed;
	 /*  top: 0;
	   left: 0; */
	   z-index: 100;
	   display: flex;
	   align-items: center;
	   flex-direction: column;
	   right: ;
   }
   .gif .img1{
	   width: 100%;
	   height: auto;
   }
   .gif .img2{
	   width: auto;
	   height: 200upx;
	   
   }
   .gif video{
	   width: 1upx;
	   height: 1upx;
   }
   .show{
	   width: 60%;
	   height: 60%;
	   margin: 30upx 0;
	   margin-bottom: 10upx;
   }
   .title{
    font-size: 24rpx;
    color: #FFF;
    text-shadow: 5rpx 4rpx 6rpx #000;
   }
</style>
